package com.summer.data.jql;

import com.summer.data.jql.behavior.FilterAble;
import com.summer.data.jql.concept.Field;
import com.summer.data.jql.concept.func.*;
import com.summer.data.table.BaseColumn;

public class Func {

    public static <T> CaseWhen<T> caseWhen(FilterAble filter, T then) {
        return new CaseWhen<>().cashWhen(filter, then);
    }

    public static <T> CaseWhen<T> caseWhen(FilterAble filter, Field<T> then) {
        return new CaseWhen<>().cashWhen(filter, then);
    }

    public static Concat concat(Field<?>... fields) {
        return new Concat(fields);
    }

    public static GroupConcat groupConcat(Boolean distinct, BaseColumn column) {
        return new GroupConcat(distinct, column);
    }

    public static Nvl nvl(Field field, Field result) {
        return new Nvl(field, result);
    }

    public static Nvl nvl(Field field, Field result, Field other) {
        return new Nvl(field, result, other);
    }

    public static Upper upper(BaseColumn column) {
        return new Upper(column);
    }

    public static Lower lower(BaseColumn column) {
        return new Lower(column);
    }

    //// 聚合函数

    public static <T> Count<T> count(Field<T> field) {
        return new Count(field);
    }

    public static Sum sum(BaseColumn column) {
        return new Sum(column);
    }

}
